Skip to content

fix(previewer): disable PDF.js streaming and range requests#811

Merged
kpsherva merged 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/pdf-previewer-disable-range-stream
Jun 11, 2026
Merged

fix(previewer): disable PDF.js streaming and range requests#811
kpsherva merged 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/pdf-previewer-disable-range-stream

Conversation

@TahaKhan998

Copy link
Copy Markdown

PDF previews were triggering duplicate network requests for the same file (the network tab showed the PDF being loaded twice). This adds PREVIEWER_PDF_JS_DOCUMENT_INIT_PARAMS to disable PDF.js streaming, range requests, and auto-fetch, so each preview loads the document in one request instead of multiple partial fetches against the server.

Comment thread invenio.cfg
PREVIEWER_PDF_JS_DOCUMENT_INIT_PARAMS = {
"disableStream": True,
"disableRange": True,
"disableAutoFetch": True,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curiosity: what did the autofetch do?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableAutoFetch stops PDF.js from downloading extra bits of the PDF in the background before you actually need them like when you scroll down to the second page of the pdf, autofetch would fetch bits for the second page while you're scrolling so I turned off all three (disableRange, disableStream, disableAutoFetch) so the preview loads the file in one go instead of several small requests to the same PDF

@kpsherva kpsherva moved this to In review 🔍 in Sprint Q2 2026 ☀️ Jun 11, 2026
@kpsherva kpsherva merged commit d23d3cc into CERNDocumentServer:master Jun 11, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from In review 🔍 to To release 🤖 in Sprint Q2 2026 ☀️ Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants